<template>
  <div id="Shopping">
    <div class="bg"></div>
    <div class="sarch">
      <van-search placeholder="搜索喜欢的商品" v-model="value" @search="onSearch" />
    </div>
    <van-list
      v-model="loading"
      :finished="finished"
      @load="onLoad"
    >
      <van-tabs v-model="active" sticky >
        <van-tab v-for="(item,k) in nav" :key="k" :title=item>
          <div class="list">
            <div  v-for="(item,k) in list" :key="k"  @click="$router.push({path:'/goods'})" class="good-list">
              <img src="/static/img/good.png"/>
              <div>
                <span>韩都衣舍2018秋装新款</span>
                <div><span>￥79.9</span><span>原价 <del>￥17.90</del></span></div>
                <div class="lq">
                  <div><img src="/static/img/lq.png"/><span>领券  7元</span></div>
                  <span>已售5.1万</span>
                </div>
                <div class="yg">
                  <div>预估赚￥5.20</div>
                  <div>升级赚￥5.20</div>
                </div>
              </div>
            </div>
          </div>
        </van-tab>
      </van-tabs>
    </van-list>
  </div>
</template>

<script>
    export default {
        name: "shopping",
      data() {
        return {
          active: 0,
          value:'',
          list: [1,1,1,1,1,1,],
          nav:["全部","洗护","内衣","百货","家电","家具","数码"],
          loading: false,
          finished: false
        };
      },
      methods: {
        onSearch() {
          var $this=this;
          alert($this.value)
        },
        onLoad() {
          // 异步更新数据
          setTimeout(() => {
            for (let i = 0; i < 5; i++) {
              this.list.push(this.list.length + 1);
            }
            // 加载状态结束
            this.loading = false;

            // 数据全部加载完成
            if (this.list.length >= 40) {
              this.finished = true;
            }
          }, 500);
        }
      }
    }
</script>

<style scoped>
  .count{
    width: 100%;
    float: left;
    margin-bottom:60px;
  }
  .count>div{
    width: 100%;
    background: #ffffff;
    padding-top:10px;
    float: left;
  }
  .count>div>p{
    text-align:left;
    margin: 0;
    margin-left: 2%;
    margin-bottom:10px;
    padding-left: 10px;
    border-left: 3px solid #fe513f;
    color: #fe513f;
  }
  .details{
    background: #eeeeee;
    width:49%;
    float: left;
    margin-left:0.5%;
    margin-top:6px;
  }
  .details>div{
    width:100%;
    display: inline-block;
  }
  .details>div>img{
    display: block;
    width: 100%;
    border-top-left-radius:10px;
    border-top-right-radius:10px;
  }
  .details>div:last-child{
    background: #ffffff;
    position: relative;
    top: -5px;
    text-align: left;
    border-bottom-left-radius:10px;
    border-bottom-right-radius:10px;
    padding-bottom:5px;
  }
  .details>div:last-child>span{
    display: block;
    width: 95%;
    margin: 0 auto;
    font-size: 16px;
  }
  .details>div:last-child>div{
    margin-top: 15px;
  }
  .details>div:last-child>div>span:first-child{
    font-size: 22px;
    color: #fe513f;
  }
  .details>div:last-child>div>span:nth-child(2){
    font-size:14px;
    color: #959595;
    margin-left: 3px;
  }
  .details>div:last-child>div>span:last-child{
    font-size:14px;
    color: #fe513f;
    display: inline-block;
    padding: 1px 3px;
    border: 1px solid #fe513f;
    border-radius:10px;
    position: relative;
    right:4px;
    top: 3px;
    float: right;
  }
  .good-list{
    width: 95%;
    text-align: left;
    margin: 0 auto;
    margin-bottom: 10px;
  }
  .good-list:after{
    clear:both;
    content:'';
    display:block;
    width:0;
    height:0;
    visibility:hidden;
  }
  .list:after{
    clear:both;
    content:'';
    display:block;
    width:0;
    height:0;
    visibility:hidden;
  }
  .good-list>img{
    float: left;
    width: 50%;
  }
  .good-list>div{
    width: 48%;
    float: left;
    text-align:left;
    margin-left:2%;
  }
  .good-list>div>span{
    font-family: 黑体;
    font-size: 18px;
    font-weight: bold;
  }
  .good-list>div>div>span:first-child {
    font-size: 20px;
    color:#e12532;
  }
  .good-list>div>div>span:last-child{
    font-size: 13px;
    float:right;
    line-height: 26px;
    color: #a8a9a9;
  }
  .good-list>div>div{
    margin-top: 15px;
  }
  .good-list>div>div:after{
    content:"";
    display:block;
    height:0;
    clear:both;
    visibility:hidden;
  }
  .lq{
    width: 100%;
  }
  .lq:after{
    clear:both;
    content:'';
    display:block;
    width:0;
    height:0;
    visibility:hidden;
  }
  .lq>div{
    width: 40%;
    position: relative;
  }
  .lq>div:first-child{
    float: left;
    height:30px;
  }
  .lq>div>img{
    position: absolute;
    top: 0;
    left: 0;
    z-index: 0;
    display: block;
    width: 100%;
  }
  .lq>div>span{
    z-index: 1;
    text-align: right;
    line-height:25px;
    position: absolute;
    right:5px;
    color: #ffffff;
    font-size: 14px;
  }
  .yg{
    width: 100%;
    font-size: 12px;
  }
  .yg>div:first-child{
    float: left;
    padding: 2px 5px;
    background: #ffdcdc;
    color: #e12532;
    border-radius:7px;
  }
  .yg>div:last-child{
    float: right;
    padding: 2px 5px;
    background: linear-gradient(to right,#ff722d, #ff4b26 , #ff2820); /* 标准的语法 */
    border-radius:7px;
    color: #ffffff;
  }
  .list{
    margin-top: 10px;
  }
</style>
<style>
  body{
    background: #ffffff;
  }
  #Shopping .van-search{
    padding: 15px!important;
    background: #ffffff!important;
  }
  #Shopping .van-search .van-cell{
    border-radius: 25px;
    background: #f7f7f7;
    padding:3px 10px;
  }
  #Shopping .van-swipe{
    width: 100%;
  }
  #Shopping .van-swipe-item>img{
    display: block;
    width: 100%;
    height: 100%;
  }
  .van-notice-bar{
    background: #ffffff;
    color: #fe513f;
  }
  .van-notice-bar__wrap{
    margin-left:10px;
  }
  .bg{
    position: absolute;
    width: 100%;
    height: 100%;
    background:#ffffff;
    z-index: -2
  }
  #Shopping .van-tabs__wrap--scrollable .van-tab{
    flex:1;
  }
</style>
